<template>
	<view class="container">


		<!-- 小程序头部兼容 -->
		<!-- #ifdef MP -->
		<view class="mp-search-box">
			<input class="ser-input" type="text" value="输入关键字搜索" />
		</view>
		<!-- #endif -->
		<!-- 头部轮播 -->
		<image src="/static/img/2/2-22.png" class="over-view"></image>
		<view class="header-box">
			<view class="header-img">
				<image src="/static/img/1/39.png" mode="aspectFill"></image>


			</view>
			<view class="header-info">
				<text class="name clamp">甘甜水果绿色店</text>
				<text class="fans">粉丝数：98700</text>
			</view>
			<view class="header-collect">
				<image src="/static/img/2/2-13.png" mode="aspectFit"></image>关注
			</view>
		</view>
		<view class="tab-box">
			<text class="item active">首页</text>
			<text class="item">商品</text>
			<text class="item">热销</text>
			<text class="item">上新</text>
			<text class="item">动态</text>
		</view>
		<view class="carousel-section">
			<!-- 标题栏和状态栏占位符 -->
			<view class="titleNview-placing"></view>
			<!-- 背景色区域 -->
			<view class="titleNview-background" :style="{backgroundColor:titleNViewBackground}"></view>
			<swiper class="carousel" circular @change="swiperChange" indicator-dots=true indicator-active-color=#fff>
				<swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item">
					<image :src="item.src" mode="aspectFill" />
				</swiper-item>
			</swiper>


		</view>
		
		
		<!-- 活动优惠 -->
		<view class="activity">
			<view class="f-header m-t">
				<view class="tit-box">
					<text class="line"></text>
					<text class="tit">热卖商品</text>
					<text class="line"></text>
				</view>
			</view>
			<view class="goods-box">
				<view class="left">
					<view class="top">
						<text class="timer">智利加力果</text>
						<image src="/static/img/1/90.png" mode="aspectFill"></image>
					</view>
					<view class="bottom">
						<text class="title">智利加力果</text>
						<image src="/static/img/1/65.png" mode="aspectFill"></image>
					</view>
				</view>
				<view class="right">
					<view class="top">
						<text class="hot">热销</text>
						<text class="timer">智利加力果</text>
						<image src="/static/img/1/77.png" mode="aspectFill"></image>
					</view>
					<view class="bottom">
						<text class="hot">热销</text>
						<text class="timer">智利加力果</text>
						<image src="/static/img/1/78.png" mode="aspectFill"></image>
					</view>
					<view class="bottom">
						<text class="hot">热销</text>
						<text class="timer">智利加力果</text>
						<image src="/static/img/1/78.png" mode="aspectFill"></image>
					</view>
				</view>
			</view>
		</view>
		
		<view class="goodslist">
			<view class="list-item">
				<image src="/static/img/1/78.png" mode="aspectFill"></image>
				<view class="list-info left">
					<text class="name">新鲜泰国芒果</text>
					<text class="desc">益胃止呕，解渴利尿</text>
					<text class="price">￥50.00</text>
				</view>
			</view>
			<view class="list-item">
				<view class="list-info right">
					<text class="name">新鲜泰国芒果</text>
					<text class="desc">益胃止呕，解渴利尿</text>
					<text class="price">￥50.00</text>
				</view>
				<image src="/static/img/1/78.png" mode="aspectFill"></image>
				
			</view>
		</view>

		<Guess></Guess>
		<!-- 分享 -->
		<share 
			ref="share" 
			:contentHeight="900"
			:shareList="shareList"
		></share>
	</view>
</template>

<script>
	import Guess from "../../components/like/guess2.vue"
	import share from '@/components/share';
	export default {
		components: {
			Guess,
			share
		},
		data() {
			return {
				titleNViewBackground: 'none',
				swiperCurrent: 0,
				swiperLength: 3,
				shareList: [],
				carouselList: [{
						src: "/static/img/1/105.png",
						background: "none",
					},
					{
						src: "/static/img/1/105.png",
						background: "none",
					},
					{
						src: "/static/img/1/105.png",
						background: "none",
					},
				]
				
				
			};
		},

		async onLoad(options) {
			// this.loadData();
			this.shareList = await this.$api.json('shareList');
		},

		methods: {
			//轮播图切换修改背景色
			swiperChange(e) {
				const index = e.detail.current;
				this.swiperCurrent = index;
				this.titleNViewBackground = this.carouselList[index].background;
			},
			
			//详情页
			navToDetailPage(item) {
				//测试数据没有写id，用title代替
				let id = item.title;
				uni.navigateTo({
					url: `/pages/detail/index?id=${id}`
				})
			},
			top() {
				uni.navigateTo({
					url: `/pages/inner/top`
				})
			},
			discount() {
				uni.navigateTo({
					url: `/pages/inner/discount`
				})
			}
		},
		// 标题栏input搜索框点击
		onNavigationBarSearchInputClicked: async function(e) {
			uni.navigateTo({
				url: `/pages/search/search`
			})
		},
		onNavigationBarButtonTap(e) {
			// console.log(e)
			
			this.$refs.share.toggleMask();
		
				
		}

	}
</script>

<style lang="scss">
	/* #ifdef MP */
	.mp-search-box {
		position: absolute;
		left: 0;
		top: 30upx;
		z-index: 9999;
		width: 100%;
		padding: 0 80upx;

		.ser-input {
			flex: 1;
			height: 56upx;
			line-height: 56upx;
			text-align: center;
			font-size: 28upx;
			color: $font-color-base;
			border-radius: 20px;
			background: rgba(255, 255, 255, .6);
		}
	}

	page {
		.cate-section {
			position: relative;
			z-index: 5;
			border-radius: 16upx 16upx 0 0;
			margin-top: -20upx;
		}

		.carousel-section {
			padding: 0;

			.titleNview-placing {
				padding-top: 0;
				height: 0;
			}

			.carousel {
				.carousel-item {
					padding: 0;
				}
			}

			.swiper-dots {
				left: 45upx;
				bottom: 40upx;
			}
		}
	}

	/* #endif */


	page {
		position: relative;
		background: #f5f5f5;
		top: -88upx;
	}



	.m-t {
		margin-top: 16upx;
	}

	.over-view {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		width: 100%;
		height: 503upx;
		// filter: blur(3upx);
		border-bottom-left-radius: 50upx;
		border-bottom-right-radius: 50upx;
	}

	.header-box {
		position: absolute;
		width: 100%;
		top: 180upx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 26upx;

		.header-img {
			width: 104upx;
			height: 104upx;
			border-radius: 20upx;

			image {
				width: 100%;
				height: 100%;
			}

		}

		.header-info {
			width: 60%;
			color: #fff;

			.name {
				display: block;
				font-size: 29upx;
				font-family: Microsoft YaHei;
				font-weight: 400;
			}

			.fans {
				display: block;
				font-size: 23upx;
				font-family: Microsoft YaHei;
				font-weight: 400;
			}
		}

		.header-collect {
			width: 94upx;
			height: 53upx;
			border-radius: 30upx;
			display: inline-flex;
			text-align: right;
			justify-content: center;
			align-items: center;

			image {
				width: 26upx;
				height: 26upx;
				margin-right: 9upx;

			}

			font-size:23upx;
			font-family:Microsoft YaHei;
			font-weight:400;
			color: #fff;
			border: 2upx solid #fff;
		}
	}

	.tab-box {
		position: absolute;
		
		width: 100%;
		top: 320upx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 26upx;
		font-size:23upx;
		font-family:Microsoft YaHei;
		font-weight:400;
		color: #fff;
		text{
			padding-bottom: 10upx;
			
		}
		.active{
			border-bottom: 2upx solid #fff;
		}

	}
	/*商品列表*/
	.goodslist{
		padding: 0 26upx;
		.list-item{
			background: #fff;
			padding: 26upx 0;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			margin-bottom: 31upx;
			border-radius:16upx;
			image{
				width:370upx;
				height:289upx;
			
			}
			.list-info{
				padding: 0 30upx;
				
				.name{
					display: block;
					font-size:40upx;
					font-family:CTBiaoSongSJ;
					font-weight:400;
					color:rgba(255,66,102,1);
					
				}
				.desc{
					display: block;
					font-size:25upx;
					font-family:CTBiaoSongSJ;
					font-weight:400;
					color:rgba(0,0,0,1);
					
				}
				.price{
					width:163upx;
					height:45upx;
					background:rgba(255,47,87,1);
					border-radius:22upx;
					font-size:25upx;
					font-family:Microsoft YaHei;
					font-weight:400;
					color:rgba(255,255,255,1);
					display: flex;
					justify-content: center;
					align-items: center;
					margin-top: 33upx;
				}
				
			}
			.left{
				image{
					
				}
			}
		}
	}
	/* 头部 轮播图 */
	.carousel-section {
		position: relative;
		padding-top: 10px;

		.titleNview-placing {
			height: var(--status-bar-height);
			padding-top: 377upx;
			box-sizing: content-box;
		}


		.titleNview-background {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 856upx;
			transition: .4s;
		}
	}

	.carousel {
		width: 100%;
		height: 856upx;

		.carousel-item {
			width: 100%;
			height: 100%;
			padding: 0 26upx;
			overflow: hidden;
		}

		image {
			width: 100%;
			height: 100%;
			border-radius: 10upx;
		}
	}

	.swiper-dots {
		display: flex;
		position: absolute;
		left: 60upx;
		bottom: 15upx;
		width: 72upx;
		height: 36upx;
		background-image: url();
		background-size: 100% 100%;

		.num {
			width: 36upx;
			height: 36upx;
			border-radius: 50px;
			font-size: 24upx;
			color: #fff;
			text-align: center;
			line-height: 36upx;
		}

		.sign {
			position: absolute;
			top: 0;
			left: 50%;
			line-height: 36upx;
			font-size: 12upx;
			color: #fff;
			transform: translateX(-50%);
		}
	}


	/* 活动优惠 */
	.activity {
		padding: 4upx 30upx 24upx;

		// background: #fff;
			.f-header{
				display:flex;
				align-items:center;
				height: 115upx;
				padding: 6upx 30upx 8upx;
				.tit-box{
					flex: 1;
					display: flex;
					// flex-direction: column;
					justify-content: center;
					align-items: center;
					.tit{
						display: inline-block;
						font-size:29upx;
						font-family:Microsoft YaHei;
						font-weight:400;
						color:rgba(4,0,0,1);
						margin: 0 10upx;
					}
					.line{
						display: inline-block;
						width:15upx;
						height:2upx;
						background:rgba(102,102,102,1)
					}
				}
				
				
			}

		.goods-box {
			display: flex;

			.left {
				width: 343upx;
				margin-right: 13upx;
				display: flex;
				flex-wrap: wrap;

				.top {
					width: 100%;
					height: 303upx;
					margin-bottom: 17upx;
					position: relative;

					.timer {
						
						color: #fff;
						position: absolute;
						z-index: 1;
						bottom: 40upx;
						left: 28upx;
						font-size:23upx;
						font-family:Adobe Heiti Std;
						font-weight:normal;
						color:rgba(255,255,255,1);
					}

					image {
						width: 100%;
						height: 100%;
					}
				}

				.bottom {
					width: 100%;
					height: 303upx;
					position: relative;

					.title {
						color: #fff;
						position: absolute;
						z-index: 1;
						bottom: 40upx;
						left: 28upx;
						font-size:23upx;
						font-family:Adobe Heiti Std;
						font-weight:normal;
						color:rgba(255,255,255,1);
					}

					image {
						width: 100%;
						height: 100%;
					}
				}
			}

			.right {
				width: 343upx;
				display: flex;
				flex-wrap: wrap;

				.top {
					width: 100%;
					height: 198upx;
					margin-bottom: 14upx;
					position: relative;

					.timer {
						font-size:19upx;
						font-family:Microsoft YaHei;
						font-weight:400;
						color:rgba(4,0,0,1);
						position: absolute;
						bottom: 36upx;
						left: 26upx;
						z-index: 1;
					}
					.hot{
						font-size:18upx;
						font-family:Microsoft YaHei;
						font-weight:400;
						color:rgba(4,0,0,1);
						position: absolute;
						top: 26upx;
						left: 26upx;
						z-index: 1;
						width:45upx;
						height:26upx;
						background: rgb(240,64,111);
						color: #fff;
						display: flex;
						align-items: center;
						justify-content: center;
					}

					image {
						width: 100%;
						height: 100%;
					}
				}

				.bottom {
					width: 100%;
					height: 198upx;
					position: relative;
					margin-bottom: 14upx;

					.timer {
						font-size:19upx;
						font-family:Microsoft YaHei;
						font-weight:400;
						color:rgba(4,0,0,1);
						position: absolute;
						bottom: 36upx;
						left: 26upx;
						z-index: 1;
					}

					.hot{
						font-size:18upx;
						font-family:Microsoft YaHei;
						font-weight:400;
						color:rgba(4,0,0,1);
						position: absolute;
						top: 26upx;
						left: 26upx;
						z-index: 1;
						width:45upx;
						height:26upx;
						background: rgb(240,64,111);
						color: #fff;
						display: flex;
						align-items: center;
						justify-content: center;
					}
					image {
						width: 100%;
						height: 100%;
					}
				}
			}
		}
	}


</style>
